package com.service.Impl;

import com.mapper.UserMapper;
import com.pojo.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    /**
     *  注册用户
     * @param user
     * @return
     */
    public boolean registerUser(User user){
        return userMapper.registerUser(user)>0;
    }

    /**
     * 修改用户
     * @param user
     * @return
     */
    public boolean updateUser(User user){
        return userMapper.updateUser(user)>0;
    }

    /**
     * 列出所有的用户
     * @return
     */
    public List<User> listUser(){
        return userMapper.listUser();
    }

    /**
     * 根据用户名删除用户
     * @param username
     * @return
     */
    public  boolean deleteUserByUsername(String username){
        return userMapper.deleteUserByUsername(username)>0;
    }

    /**
     *  根据用户名查询用户
     * @param username
     * @return
     */
    public User selectByUserName(String username){
        return userMapper.selectByUserName(username);
    }
}
